﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using IHISCETeim.Library;
using System.Data;
using IHISCETeim.BLL;

namespace IHISCETeim.Web.AgentSys.VipMgr
{
    public partial class VIPExchangePartList : EasyUIPageBase
    {
        protected override Permission[] PowerKey
        {
            get
            {
                return new Permission[] { Permission.查看, Permission.修改, Permission.新增, Permission.删除 };
            }
        }
        protected override string DWZRef
        {
            get
            {
                return "VIPExchangePartList";
            }
        }
        

        #region 属性 (查询条件)
        /// <summary>
        /// 排序字段 值为 id
        /// </summary>
        protected override string orderField
        {
            get
            {
                return string.IsNullOrEmpty(base.orderField) ? "CustomerId" : base.orderField;
            }
        }
        /// <summary>
        ///  排序方式 desc或 asc
        /// </summary>
        protected override string orderDirection
        {
            get
            {
                return string.IsNullOrEmpty(base.orderDirection) ? "DESC" : base.orderDirection;
            }
        }


        protected override string SQLSort
        {
            get
            {
                return (orderField + " " + orderDirection);
            }
        }

        [QueryColumnName(), QueryOperator(QueryOperatorsEnum.包含)]
        public string ItemCode
        {
            get
            {
                return GetRequestValue<string>("ItemCode", "");

            }
        }
        [QueryColumnName(), QueryOperator(QueryOperatorsEnum.包含)]
        public string ItemName
        {
            get
            {
                return GetRequestValue<string>("ItemName", "");

            }
        }

        protected override string query()
        {
            DataTable dts = VIPExchangePartController.GetByWhere( QueryFiledHelper.GetSqlWhere(this));

            return ToDataGridJson(dts, TotalCount, null).ToString();
        }

        protected override string delrow()
        {
            if (base.User.UserType != 1)
                return "";

            int id = GetRequestValue<int>("ID", 0);
            bool r = VIPExchangePartController.Delete(id);
            if (r)
                SuccessJson("已成功删除", this.DWZRef);
            else
                ErrorJson("删除失败");

            return "";
        }

        #endregion
    }
}